-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix EHR sql server error #5123
Fix EHR sql server error #5123
Conversation
@@ -4976,7 +4980,7 @@ else if (scope != tableInfo.getSchema().getScope()) | |||
} | |||
commandObject.put("extraContext", commandExtraContext); | |||
|
|||
JSONObject commandResponse = executeJson(commandObject, command, transacted, errors); | |||
JSONObject commandResponse = executeJson(commandObject, command, !transacted, errors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't quite get why this got switched to !transacted
. This says if it's not transacted we'll allow transaction if the JSON property is true, but if it is transacted here and that property is true, we don't allow transactions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been like this for 12 years. I think it got flipped because it was trying to avoid nested transaction and have the outer transaction used only. Attempt to reverse is resulted in sql server transaction already rolled back error.
auditEvent = transaction.getAuditEvent(); | ||
DbScope.Transaction auditTransaction = transacted ? transaction : table.getSchema().getScope().getCurrentTransaction(); | ||
if (auditTransaction == null) | ||
auditTransaction = transaction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this. If transacted
is true, we use the ensured transaction from the try block and if it's false we get the transaction from the table schema. Presumably if it's transacted, these are the same thing. If there is no transaction on the table schema, we use the NO_OP_TRANSACTION
. So could this be
`
auditTransaction = transaction; | |
DbScope.Transaction auditTransaction = table.getSchema().getScope().getCurrentTransaction(); | |
if (auditTransaction == null) | |
auditTransaction = NO_OP_TRANSACTION; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've modified the logic a little bit more to only get scope transaction when the outer caller is indeed transacted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. That's a bit more understandable
Rationale
#5089 introduced a change to use the same transaction in a nested way. This turns out to be causing issues for sql server, see related failures
This PR reverts the !transacted change to use NO_OP transaction for the inner transaction, and seek to handle transaction audit on an alternative current transaction.
Good run
Related Pull Requests
Changes